
--打进来的欢迎语音菜单
session:consoleLog("info","->进入欢迎的语音菜单");

--一定要先answer 才能向对端播放语音菜单
session:answer();
session:setAutoHangup(false)



local queuename="necoagent";

while(session:ready()==true) do

	local digit=session:playAndGetDigits(1, 1, 3, 1000, "#", 
	"/usr/local/freeswitch/sounds/welcome.wav",
	 "",
	 "\\d+")	
	
	if(digit == "0") then

		local api = freeswitch.API();

		local reply=api:executeString("callcenter_config  queue count  members  "..queuename);

		--计算排队的人数去掉空格
		reply=string.gsub(reply, "^%s*(.-)%s*$", "%1");

		local sayreply="zh NUMBER PRONOUNCED "..reply;
		session:consoleLog("info","execute---"..sayreply);
	
		--向对端播放排队人数
		local inqueue=tonumber(reply);
		
		--如果是1就是他本身，无需提示
		if(inqueue >1) then
			session:streamFile("/usr/local/freeswitch/sounds/tipqueuecount.wav");
        	        session:execute("say",sayreply);
	                session:streamFile("/usr/local/freeswitch/sounds/tipinqueue.wav");
		end;

		--打印日志进入call center模块，在进入了call center模块之后全权给cc处理
		session:consoleLog("info","进入callcenter");
		session:execute("callcenter","necoagent");
		--这里不能return;
		return "break";
	end
end


